# File names
EXEC = client
SOURCES = $(wildcard *.cpp)
OBJECTS = $(SOURCES:.cpp=.o)

# SDL
SDL_LIB = -L/usr/local/lib -Wl,-rpath,/usr/local/lib -lSDL2_image -lSDL2_mixer -lSDL2_ttf -lSDL2 -lpthread 
SDL_INCLUDE = -I/usr/local/include/SDL2 -I../common -D_REENTRANT

CC = g++
CC_FLAGS = -Wall -g -c --std=c++98 $(SDL_INCLUDE)
LDFLAGS = $(SDL_LIB)

# Main target
$(EXEC): $(OBJECTS)
	cd ../common && $(MAKE)
	cp ../common/common.a .
	$(CC) $(OBJECTS) common.a $(LDFLAGS) -o $(EXEC)

# To obtain object files
%.o: %.cpp 
	$(CC) $(CC_FLAGS) $< -o $@

# To remove generated files
clean:
	rm -f $(EXEC) $(OBJECTS) common.a

all: $(EXEC)

.PHONY: all